/*     */ package dm.sql;
/*     */ 
/*     */ import dm.jdbc.dataConvertion.CType2JType;
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import java.io.InputStream;
/*     */ import java.io.Reader;
/*     */ import java.math.BigDecimal;
/*     */ import java.net.URL;
/*     */ import java.sql.Array;
/*     */ import java.sql.Blob;
/*     */ import java.sql.Clob;
/*     */ import java.sql.Date;
/*     */ import java.sql.Ref;
/*     */ import java.sql.SQLException;
/*     */ import java.sql.SQLInput;
/*     */ import java.sql.Struct;
/*     */ import java.sql.Time;
/*     */ import java.sql.Timestamp;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class DmdbSQLInput
/*     */   implements SQLInput
/*     */ {
/*     */   private Object[] m_attribs;
/*  33 */   private int index = 0;
/*  34 */   private boolean isNull = false;
/*     */   private Map map;
/*     */   
/*     */   public DmdbSQLInput(Map map, Object[] attributes) {
/*  38 */     this.m_attribs = attributes;
/*  39 */     this.index = 0;
/*  40 */     this.isNull = false;
/*  41 */     this.map = map;
/*     */   }
/*     */   
/*     */   public String readString()
/*     */     throws SQLException
/*     */   {
/*  47 */     checkIndex(this.index);
/*     */     
/*  49 */     Object obj = this.m_attribs[this.index];
/*  50 */     this.index += 1;
/*     */     String retVal;
/*  52 */     String retVal; if (obj == null) {
/*  53 */       this.isNull = true;
/*  54 */       retVal = null;
/*     */     } else {
/*  56 */       this.isNull = false;
/*  57 */       if (((obj instanceof Array)) || ((obj instanceof Struct)) || 
/*  58 */         ((obj instanceof Clob)) || ((obj instanceof Blob)) || 
/*  59 */         ((obj instanceof byte[]))) {
/*  60 */         DBError.throwSQLException(6007);
/*     */       }
/*  62 */       retVal = obj.toString();
/*     */     }
/*     */     
/*  65 */     return retVal;
/*     */   }
/*     */   
/*     */   public boolean readBoolean()
/*     */     throws SQLException
/*     */   {
/*  71 */     checkIndex(this.index);
/*     */     
/*  73 */     Object obj = this.m_attribs[this.index];
/*  74 */     this.index += 1;
/*     */     boolean retVal;
/*  76 */     boolean retVal; if (obj == null) {
/*  77 */       this.isNull = true;
/*  78 */       retVal = false;
/*     */     } else {
/*  80 */       this.isNull = false;
/*  81 */       retVal = ((Boolean)obj).booleanValue();
/*     */     }
/*  83 */     return retVal;
/*     */   }
/*     */   
/*     */   public byte readByte() throws SQLException {
/*  87 */     byte retVal = 0;
/*     */     
/*  89 */     checkIndex(this.index);
/*     */     
/*  91 */     Object obj = this.m_attribs[this.index];
/*  92 */     this.index += 1;
/*     */     
/*  94 */     if (obj == null) {
/*  95 */       this.isNull = true;
/*     */     } else {
/*  97 */       this.isNull = false;
/*  98 */       retVal = ((Byte)obj).byteValue();
/*     */     }
/* 100 */     return retVal;
/*     */   }
/*     */   
/*     */   public short readShort() throws SQLException {
/* 104 */     short retVal = 0;
/*     */     
/* 106 */     checkIndex(this.index);
/*     */     
/* 108 */     Object obj = this.m_attribs[this.index];
/* 109 */     this.index += 1;
/*     */     
/* 111 */     if (obj == null) {
/* 112 */       this.isNull = true;
/*     */     } else {
/* 114 */       this.isNull = false;
/* 115 */       if ((!(obj instanceof Number)) && (!(obj instanceof String))) {
/* 116 */         DBError.throwSQLException(6007);
/*     */       }
/* 118 */       retVal = Short.parseShort(obj.toString());
/*     */     }
/* 120 */     return retVal;
/*     */   }
/*     */   
/*     */   public int readInt() throws SQLException {
/* 124 */     int retVal = 0;
/*     */     
/* 126 */     checkIndex(this.index);
/*     */     
/* 128 */     Object obj = this.m_attribs[this.index];
/* 129 */     this.index += 1;
/*     */     
/* 131 */     if (obj == null) {
/* 132 */       this.isNull = true;
/*     */     } else {
/* 134 */       this.isNull = false;
/* 135 */       if ((!(obj instanceof Number)) && (!(obj instanceof String))) {
/* 136 */         DBError.throwSQLException(6007);
/*     */       }
/* 138 */       retVal = Integer.parseInt(obj.toString());
/*     */     }
/* 140 */     return retVal;
/*     */   }
/*     */   
/*     */   public long readLong() throws SQLException {
/* 144 */     long retVal = 0L;
/*     */     
/* 146 */     checkIndex(this.index);
/*     */     
/* 148 */     Object obj = this.m_attribs[this.index];
/* 149 */     this.index += 1;
/*     */     
/* 151 */     if (obj == null) {
/* 152 */       this.isNull = true;
/*     */     } else {
/* 154 */       this.isNull = false;
/* 155 */       if ((!(obj instanceof Number)) && (!(obj instanceof String))) {
/* 156 */         DBError.throwSQLException(6007);
/*     */       }
/* 158 */       retVal = Long.parseLong(obj.toString());
/*     */     }
/* 160 */     return retVal;
/*     */   }
/*     */   
/*     */   public float readFloat() throws SQLException {
/* 164 */     float retVal = 0.0F;
/*     */     
/* 166 */     checkIndex(this.index);
/*     */     
/* 168 */     Object obj = this.m_attribs[this.index];
/* 169 */     this.index += 1;
/*     */     
/* 171 */     if (obj == null) {
/* 172 */       this.isNull = true;
/*     */     } else {
/* 174 */       this.isNull = false;
/* 175 */       if ((!(obj instanceof Number)) && (!(obj instanceof String))) {
/* 176 */         DBError.throwSQLException(6007);
/*     */       }
/* 178 */       retVal = Float.parseFloat(obj.toString());
/*     */     }
/* 180 */     return retVal;
/*     */   }
/*     */   
/*     */   public double readDouble() throws SQLException {
/* 184 */     double retVal = 0.0D;
/*     */     
/* 186 */     checkIndex(this.index);
/*     */     
/* 188 */     Object obj = this.m_attribs[this.index];
/* 189 */     this.index += 1;
/*     */     
/* 191 */     if (obj == null) {
/* 192 */       this.isNull = true;
/*     */     } else {
/* 194 */       this.isNull = false;
/* 195 */       if ((!(obj instanceof Number)) && (!(obj instanceof String))) {
/* 196 */         DBError.throwSQLException(6007);
/*     */       }
/* 198 */       retVal = Double.parseDouble(obj.toString());
/*     */     }
/* 200 */     return retVal;
/*     */   }
/*     */   
/*     */   public BigDecimal readBigDecimal() throws SQLException {
/* 204 */     BigDecimal retVal = null;
/*     */     
/* 206 */     checkIndex(this.index);
/*     */     
/* 208 */     Object obj = this.m_attribs[this.index];
/* 209 */     this.index += 1;
/*     */     
/* 211 */     if (obj == null) {
/* 212 */       this.isNull = true;
/*     */     } else {
/* 214 */       this.isNull = false;
/* 215 */       if ((obj instanceof BigDecimal)) {
/* 216 */         retVal = (BigDecimal)obj;
/*     */       } else {
/* 218 */         if ((!(obj instanceof Number)) && (!(obj instanceof String))) {
/* 219 */           DBError.throwSQLException(6007);
/*     */         }
/* 221 */         retVal = new BigDecimal(obj.toString());
/*     */       }
/*     */     }
/* 224 */     return retVal;
/*     */   }
/*     */   
/*     */   public byte[] readBytes() throws SQLException {
/* 228 */     byte[] retVal = null;
/*     */     
/* 230 */     checkIndex(this.index);
/*     */     
/* 232 */     Object obj = this.m_attribs[this.index];
/* 233 */     this.index += 1;
/*     */     
/* 235 */     if (obj == null) {
/* 236 */       this.isNull = true;
/*     */     } else {
/* 238 */       this.isNull = false;
/* 239 */       retVal = (byte[])obj;
/*     */     }
/* 241 */     return retVal;
/*     */   }
/*     */   
/*     */   public Date readDate() throws SQLException {
/* 245 */     Date retVal = null;
/*     */     
/* 247 */     checkIndex(this.index);
/*     */     
/* 249 */     Object obj = this.m_attribs[this.index];
/* 250 */     this.index += 1;
/*     */     
/* 252 */     if (obj == null) {
/* 253 */       this.isNull = true;
/*     */     } else {
/* 255 */       this.isNull = false;
/* 256 */       retVal = (Date)obj;
/*     */     }
/* 258 */     return retVal;
/*     */   }
/*     */   
/*     */   public Time readTime() throws SQLException {
/* 262 */     Time retVal = null;
/*     */     
/* 264 */     checkIndex(this.index);
/*     */     
/* 266 */     Object obj = this.m_attribs[this.index];
/* 267 */     this.index += 1;
/*     */     
/* 269 */     if (obj == null) {
/* 270 */       this.isNull = true;
/*     */     } else {
/* 272 */       this.isNull = false;
/* 273 */       retVal = (Time)obj;
/*     */     }
/* 275 */     return retVal;
/*     */   }
/*     */   
/*     */   public Timestamp readTimestamp() throws SQLException {
/* 279 */     Timestamp retVal = null;
/*     */     
/* 281 */     checkIndex(this.index);
/*     */     
/* 283 */     Object obj = this.m_attribs[this.index];
/* 284 */     this.index += 1;
/*     */     
/* 286 */     if (obj == null) {
/* 287 */       this.isNull = true;
/*     */     } else {
/* 289 */       this.isNull = false;
/* 290 */       retVal = (Timestamp)obj;
/*     */     }
/* 292 */     return retVal;
/*     */   }
/*     */   
/*     */   public Reader readCharacterStream() throws SQLException {
/* 296 */     DBError.throwUnsupportedSQLException();
/* 297 */     return null;
/*     */   }
/*     */   
/*     */   public InputStream readAsciiStream() throws SQLException {
/* 301 */     DBError.throwUnsupportedSQLException();
/* 302 */     return null;
/*     */   }
/*     */   
/*     */   public InputStream readBinaryStream() throws SQLException {
/* 306 */     DBError.throwUnsupportedSQLException();
/* 307 */     return null;
/*     */   }
/*     */   
/*     */   public Object readObject() throws SQLException {
/* 311 */     Object retVal = null;
/*     */     
/* 313 */     checkIndex(this.index);
/*     */     
/* 315 */     Object obj = this.m_attribs[this.index];
/* 316 */     this.index += 1;
/*     */     
/* 318 */     if (obj == null) {
/* 319 */       this.isNull = true;
/*     */     } else {
/* 321 */       this.isNull = false;
/* 322 */       if ((obj instanceof STRUCT)) {
/* 323 */         STRUCT struct = (STRUCT)obj;
/* 324 */         retVal = CType2JType.getStruct_SQLData(this.map, struct, 
/* 325 */           struct.getSQLTypeName());
/*     */       } else {
/* 327 */         retVal = obj;
/*     */       }
/*     */     }
/* 330 */     return retVal;
/*     */   }
/*     */   
/*     */   public Ref readRef() throws SQLException {
/* 334 */     DBError.throwUnsupportedSQLException();
/* 335 */     return null;
/*     */   }
/*     */   
/*     */   public Blob readBlob() throws SQLException {
/* 339 */     Blob retVal = null;
/*     */     
/* 341 */     checkIndex(this.index);
/*     */     
/* 343 */     Object obj = this.m_attribs[this.index];
/* 344 */     this.index += 1;
/*     */     
/* 346 */     if (obj == null) {
/* 347 */       this.isNull = true;
/*     */     } else {
/* 349 */       this.isNull = false;
/* 350 */       retVal = (Blob)obj;
/*     */     }
/* 352 */     return retVal;
/*     */   }
/*     */   
/*     */   public Clob readClob() throws SQLException {
/* 356 */     Clob retVal = null;
/*     */     
/* 358 */     checkIndex(this.index);
/*     */     
/* 360 */     Object obj = this.m_attribs[this.index];
/* 361 */     this.index += 1;
/*     */     
/* 363 */     if (obj == null) {
/* 364 */       this.isNull = true;
/*     */     } else {
/* 366 */       this.isNull = false;
/* 367 */       retVal = (Clob)obj;
/*     */     }
/* 369 */     return retVal;
/*     */   }
/*     */   
/*     */   public Array readArray() throws SQLException {
/* 373 */     Array retVal = null;
/*     */     
/* 375 */     checkIndex(this.index);
/*     */     
/* 377 */     Object obj = this.m_attribs[this.index];
/* 378 */     this.index += 1;
/*     */     
/* 380 */     if (obj == null) {
/* 381 */       this.isNull = true;
/*     */     } else {
/* 383 */       this.isNull = false;
/* 384 */       retVal = (Array)obj;
/*     */     }
/* 386 */     return retVal;
/*     */   }
/*     */   
/*     */   public boolean wasNull() throws SQLException {
/* 390 */     return this.isNull;
/*     */   }
/*     */   
/*     */   public URL readURL() throws SQLException {
/* 394 */     DBError.throwUnsupportedSQLException();
/* 395 */     return null;
/*     */   }
/*     */   
/*     */   private void checkIndex(int index) throws SQLException {
/* 399 */     if ((index < 0) || (index >= this.m_attribs.length)) {
/* 400 */       DBError.throwSQLException(6032);
/*     */     }
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\sql\DmdbSQLInput.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */